<?php

function getTableList($dbDatabase,$dbUsername,$dbPassword,$dbServer = 'localhost'){
	$workdb = mysql_connect($dbServer, $dbUsername, $dbPassword) or die(mysql_error());
	//print "Got to here 3";
	mysql_select_db($dbDatabase,$workdb)  or die(mysql_error());
	
	$qry_get_columns = "SHOW TABLES IN $dbDatabase";
	$get_results = mysql_query($qry_get_columns, $workdb) or die(mysql_error());
	//print "GotShowVars";
	$col_name = 'Tables_in_' . $dbDatabase;	
	if(mysql_num_rows($get_results)) {
		$index = 0;
		while($resultsarray = mysql_fetch_assoc($get_results)) {
	
			$colinfo[$index] = $resultsarray[$col_name];
			$index++;
		}
		mysql_close($workdb);
	return $colinfo;

	}
}
function getColumnList($table,$dbDatabase,$dbUsername,$dbPassword,$dbServer = 'localhost'){
	$workdb = mysql_connect($dbServer, $dbUsername, $dbPassword) or die(mysql_error());
	//print "Got to here 3";
	mysql_select_db($dbDatabase,$workdb)  or die(mysql_error());
	
	$qry_get_columns = "SHOW COLUMNS IN $table";
	
	$get_results = mysql_query($qry_get_columns, $workdb) or die(mysql_error());
	//print "GotShowVars";
	if(mysql_num_rows($get_results)) {
		$index = 1;
		while($resultsarray = mysql_fetch_assoc($get_results)) {
			$valuesarray[$index] = $resultsarray;
			
			$colinfo[$index]['variable_name'] = $resultsarray['Field'];
			$colinfo[$index]['type'] = $resultsarray['Type'];
			$colinfo[$index]['size'] = 20;
			if($resultsarray['Key'] == 'PRI'){
				$colinfo[$index]['is_key'] = 1;
			}
			else{
				$colinfo[$index]['is_key'] = 0;
			}
			$index ++;
			}
		
		}
		mysql_close($workdb);
	return $colinfo;


}
?>